import request from '@/utils/request'

export const getUserData = (pageinfo) => {
  return request.get('user/user/getUserList', {
    params: {
      name: pageinfo.name,
      pageSize: pageinfo.pageSize,
      pageNum: pageinfo.pageNum,
      phone: pageinfo.phone
    }
  })
}

export const updateUserState = (userId) => {
  return request.post('user/user/updateUserState?id=' + userId)
}

export const updateUserLevel = (userId) => {
  return request.post('user/user/updateUserLevel?id=' + userId)
}

export const getUserById = (userId) => {
  return request.get('user/user/getUserById',
    {
      params: {
        id: userId
      }
    })
}

export const updateUser = (adminInfo) => {
  return request.post('user/user/updateUser', adminInfo)
}

export const deleteUserById = (userId) => {
  return request.delete('user/user/deleteUserById=' + userId)
}

export const addUser = (addForm) => {
  return request.post('user/user/addUser', {
    userName: addForm.userName,
    userPhone: addForm.userPhone,
    userPassword: addForm.userPassword,
    userNickname: addForm.userNickname
  })
}
